<?php
/**
 * ------------------------------------------------------------------------
 * JA Toppanel Module for Joomla 2.5
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites: http://www.joomlart.com - http://www.joomlancers.com
 * ------------------------------------------------------------------------
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (dirname(__FILE__) . DS . 'helper.php');

$app = & JFactory::getApplication();

$helper = new modJaToppanelHelper();

$module_content = $helper->_load($params);

$show_button_close = $params->get('close', 1);
$show_dontshowagain = $params->get('dontshowagain', 0);
$transparent = $params->get('transparent', 1);
$auto_open = $params->get('auto', 0);
$overlay = $params->get('overlay', 0);
$duration = $params->get('duration', 0);
$delay = $params->get('delay', 0);
$howmanytimes = $params->get('howmanytimes', -1);
$cookie_suffix = $params->get('cookie_suffix', 'jatoppanel_');

if (isset($_COOKIE[$cookie_suffix . 'dontshowagain' . $module->id]) && $_COOKIE[$cookie_suffix . 'dontshowagain' . $module->id]) {
    return;
}
if ($howmanytimes >= 0 && $auto_open) {
    $manytimes = 0;
    if (isset($_COOKIE[$cookie_suffix . 'howmanytimes' . $module->id])) {
        $manytimes = (int) $_COOKIE[$cookie_suffix . 'howmanytimes' . $module->id];
    }
    if ($manytimes >= $howmanytimes) {
        $auto_open = 0;
    }
    setcookie($cookie_suffix . 'howmanytimes' . $module->id, $manytimes + 1);
}

if (!defined('_MODE_JATOPPANEL_ASSETS_')) {
    define('_MODE_JATOPPANEL_ASSETS_', 1);

    JHTML::stylesheet('modules/' . $module->module . '/assets/style.css');
    JHTML::script('modules/' . $module->module . '/assets/script.js', true);

    if (is_file(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . $module->module . ".css"))
        JHTML::stylesheet('templates/' . $app->getTemplate() . '/css/' . $module->module . '.css');
    if ($helper->ae_detect_ie()) {
        JHTML::stylesheet('modules/' . $module->module . '/assets/style-ie.css');
    }
}

require JModuleHelper::getLayoutPath($module->module, 'default');

